<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>文件管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/dist/css/layui.css"  media="all">
    <link rel="stylesheet" href="css/bootstrap.min.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
    <style>
        body{
            background-image: url("image/heibai.jpg");
            background-size:100% 100%;
            background-repeat: no-repeat;
            background-attachment: fixed;"
        }
        .transparentDataTable .layui-table{
            background-color: transparent !important;
        }
        .transparentDataTable .layui-table-view{
            background-color: rgba(0, 0, 0, 0.2) !important;
        }
        .transparentDataTable .layui-table-tool {
            background-color: transparent !important;
        }

        .transparentDataTable .layui-table-tool .layui-icon {
            color: white;
        }

        .transparentDataTable .layui-table-header, .transparentDataTable .layui-table-cell, .layui-table-header thead tr {
            background-color: transparent !important;
        }

        .transparentDataTable .layui-table-header thead th, .transparentDataTable .layui-none {
            /*border: 1px solid #FFFFFF;*/
            color: white !important;
        }

        .transparentDataTable .layui-table tbody tr {
            border: 1px solid #FFFFFF;
            color: white;
        }

        .transparentDataTable .layui-table-init, .transparentDataTable .layui-laypage-limits select, .transparentDataTable .layui-laypage-btn, .transparentDataTable .layui-laypage-skip input {
            background-color: transparent !important;
            color: white;
        }

        .transparentDataTable .layui-table-page a, .transparentDataTable .layui-table-page span {
            color: white !important;
        }


        .transparentDataTable .layui-laypage-limits select, .transparentDataTable .layui-laypage-limits option {
            -webkit-appearance: none; /* google */
            -moz-appearance: none; /* firefox */
            appearance: none; /* IE */
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);   /* 点击去除高亮的颜色*/
            background-color: rgba(0, 0, 0, 0.2) !important;
            color: white;
        }

        .transparentDataTable .layui-table[lay-even] tr:nth-child(even){
            background-color: rgba(180, 238, 180, 0.2) !important;
        }
        /*静态表格透明*/
        .transparentStaticTable .layui-table{
            background-color: rgba(0, 0, 0, 0.2) !important;
        }
        .transparentStaticTable .layui-table tbody tr:hover, .statistics_branch_one .layui-table tbody tr:hover {
            background-color: transparent !important;
        }
    </style>
</head>
<div class="demoTable">
    <button type="button" class="layui-btn" id="addFile">
        <i class="layui-icon">&#xe654;</i>新建文件夹
    </button>
    <button type="button" class="layui-btn layui-btn layui-btn-warm" id="uploadFile">
        <i class="layui-icon">&#xe67c;</i>上传文件
    </button>
    <button type="button" class="layui-btn layui-btn-primary" id="removeFile">
        <i class="layui-icon">&#xe640;</i>批量删除
    </button>
    <div class="layui-inline">
        <input class="layui-input" name="searchStr" id="searchStr" autocomplete="off">
    </div>
    <button class="layui-btn" data-type="button" id="searchFile">搜索</button>
</div>
<body>


<input  type="text" name="parentId" id="parentId" >
<div class="transparentDataTable">
    <table class="layui-hide" id="LAY_table_user" lay-filter="user"></table>
</div>

<script type="text/html" id="barDemo">
    <a lay-event="del" title="删除"><i class="layui-icon layui-icon-delete" style="font-size: 20px;"></i></a>
</script>

<script src="layui/dist/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
<script type="text/html" id="filenameDev">
    {{# if(d.fileType=='文件夹'){ }}
    <a href="javascript:;" onclick="searchFileOfFloder('{{d.id}}');">  <i class="glyphicon glyphicon-folder-close" style="color: #F0DA72;font-size:16px;"></i>&nbsp;{{d.fileName}}</a>
    {{# }else{ }}
    <a href="javascript:;" onclick="getFile('{{d.fileAbsolute}}');"> <i class="glyphicon glyphicon-file" style="color: #A9A9A9;font-size:16px;"></i>&nbsp;{{d.fileName}}</a>
    {{# } }}
</script>
<script th:inline='none'>
    layui.use('table', function() {
        var table = layui.table;
        var $ = layui.$;
        $("#addFloderDiv").hide();
        //方法级渲染
        table.render({
            elem: '#LAY_table_user'
            , url: 'getAllShare'
            , cols: [[
                {checkbox: true, fixed: true}
                , {field: 'fileName', title: '文件名', templet: '#filenameDev'}
                , {
                    field: 'uploadTime', title: '上传时间', width: 300, sort: true,
                    templet: "<div>{{layui.util.toDateString(d.uploadTime,'yyyy-MM-dd HH:mm:ss')}}</div>"
                }
                , {field: 'fileSize', title: '文件大小', width: 200, sort: true}
                , {field: 'fileType', title: '文件类型', width: 200, sort: true}
                , {field: 'right', title: '操作', width: 250, align: 'center', toolbar: '#barDemo'}
            ]]
            , page: true
            , id: 'testReload'
            , parseData: function (res) {
                console.log(res);
                return {
                    "code": 0,
                    "msg": res.msg,
                    "count": res.count,
                    "data": res.data
                };
            }
        });

        var $ = layui.$, active = {
            reload: function () {
                var demoReload = $('#demoReload');
                //var searchStr=$('#searchStr');
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        fileName: demoReload.val()
                    }
                });
            }

        };

        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        table.on('tool(user)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            var tr = obj.tr;
            if (layEvent == 'del') {
                deleteShare(data.fileAbsolute);
            }
        });
    });
    function deleteShare(data) {
        alert("取消分享");
        var  $=layui.$;
        $.ajax({
            url:'deleteShare',
            type:"get",
            data:{fileAbsolute:data},
            dataType:"json",
            success:function (res) {
                alert("取消分享成功");
            }
        })
        window.location.reload();
    }
</script>

</body>
</html>